<?php

require_once dirname(__FILE__).'/../lib/usersGeneratorConfiguration.class.php';
require_once dirname(__FILE__).'/../lib/usersGeneratorHelper.class.php';

/**
 * users actions.
 *
 * @package    jobeet
 * @subpackage users
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class usersActions extends autoUsersActions
{
  public function executeExportEmail()
  {
    $this->setLayout(false);
    $this->emails = Doctrine_Query::create()
              ->select('first_name, last_name, email')
              ->from('PublicUser')
              ->where('newslist = ?', 'on')
              ->fetchArray();
    $this->getResponse()->setContentType('application/txt');
    $this->getResponse()->setHttpHeader('Content-Disposition', 'attachment; filename="emails.txt"');
    foreach($this->emails as $email) {
      echo $email['first_name'] . ' ' . $email['last_name'] . ' : ' . $email['email'] . "\n";
    }
    return sfView::NONE;
  }

  public function executeRemindPassword($request){
	  
	$user = Doctrine::getTable('PublicUser')->find($request->getParameter('userId'));

	$this->getMailer()->composeAndSend('aneto1@gmail.com', $user['email'], $request->getHost().' parooli uuendus',
		'Your login: ' . $user['login'] . "\n" .
		'Your new password is: ' . $user['password'] ."\n");

	
	$this->redirect($request->getReferer());
  }
  
}
